<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
    <body>
	  <h:outputLabel value="#{ForumBean.target.course.NAME}" />
	  <h:outputLabel value="Forumu"/>
          <p:commandButton  value="Konu Ekle" action="#{ForumBean.openTab()}" update="create"/>
          <p:dataGrid paginator="true" rowsPerPageTemplate="20,100" 
                      paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  emptyMessage="Konu bulunmamaktadır." columns="1" value="#{ForumBean.target.topics}" var="topic">
		<p:column>
		<p:panel >
		    <h:panelGrid columns="3">
                        <h:graphicImage url="img/topic.gif"/>
			  <h:panelGrid columns="1">
				<strong style="font-size: 2em;">#{topic.replyCount}</strong>
				Cevap
			  </h:panelGrid>
		    <h:panelGrid columns="1">
			  <p:commandLink ajax="false" value="#{topic.header}" action="#{HomePageBean.clickTopic()}">
				<f:setPropertyActionListener value="#{topic}" target="#{ForumBean.targetTopic}"/>
			  </p:commandLink>
			  <h:panelGroup>
				<p:commandLink value="#{topic.person.fullName}" ajax="false" action="#{HomePageBean.clickStudent()}">
				    <f:setPropertyActionListener  value="#{topic.person}" target="#{StudentBean.target}"/>
				</p:commandLink>
				<h:outputLabel value=" tarafından"/>
                                <h:outputLabel value="#{topic.date.toLocaleString()} tarihinde yazıldı."/>
			  </h:panelGroup>
		    </h:panelGrid>
		    </h:panelGrid>
		</p:panel>
		</p:column>
	  </p:dataGrid>
          <p:accordionPanel id="create" activeIndex="">
		<p:tab   title="Konu Ekle" >
		<h:panelGrid columns="2">
		    <h:outputLabel value="Başlık: "/>
		    <p:inputText value="#{ForumBean.header}"/>
		</h:panelGrid>
		<p:editor value="#{ForumBean.text}"/>
		<p:commandButton value="Ekle" action="#{ForumBean.addTopic()}" ajax="false"/>
		</p:tab>
	  </p:accordionPanel>
    </body>
</html>
